package com.yupi.yuojbackendquestionservice.controller.inner;

import com.yupi.yuojbackendmodel.model.entity.Question;
import com.yupi.yuojbackendmodel.model.entity.QuestionSubmit;
import com.yupi.yuojbackendquestionservice.service.QuestionService;
import com.yupi.yuojbackendquestionservice.service.QuestionSubmitService;
import com.yupi.yuojbackendserviceclient.service.QuestionFeignClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/inner")
public class QuestionInnerController implements QuestionFeignClient {
    @Resource
    QuestionService questionService;
    @Resource
    QuestionSubmitService questionSubmitService;

    @Override
    @GetMapping("/get/id")
    public Question getQuestionByid(@RequestParam("questionId") long questionId){
        return questionService.getById(questionId);
    }

    @Override
    @GetMapping("/question_submit/get/id")
    public QuestionSubmit getQuestionSubmitByid(@RequestParam("questionSubmitId") long questionSubmitId){
        QuestionSubmit questionSubmit = questionSubmitService.getById(questionSubmitId);
        return questionSubmit;

    }

    @Override
    @PostMapping("/question_submit/update")
    public Boolean updateQuestionSubmitByid(@RequestBody QuestionSubmit questionSubmit){
        return questionSubmitService.updateById(questionSubmit);
    }

    @Override
    @PostMapping("/question/update")
    public Boolean updaById(Question question) {
        return questionService.updateById(question);
    }
}
